<script setup lang='ts'>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useTypeStore } from '@/store/type'

const router = useRouter()
const typeStore = useTypeStore()

const userInfo = ref()
onMounted(() => {
  const info = localStorage.getItem('userInfo')
  userInfo.value = JSON.parse(info)
})

const logout = () => {
  localStorage.removeItem('userInfo')
  typeStore.setActiveIndex(0)
  router.push('/login')
}

</script>


<template>
  尊敬的{{ userInfo?.name }}
  <el-button @click="logout">退出登录</el-button>
</template>


<style scoped></style>